package com.sskj.ffex.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.ffex.m.HttpConfig;
import com.sskj.ffex.m.bean.FabiDetailListBean;
import com.sskj.ffex.m.bean.HaiPageBean;
import com.sskj.ffex.m.bean.HttpData;
import com.sskj.ffex.m.http.JsonConverter;
import com.sskj.ffex.p.base.BasePresenter;
import com.sskj.ffex.v.fragment.FabiBuyAndSellDetailFragment;

import java.util.List;

import io.reactivex.Flowable;

public class FabiBuyDetailPresenter extends BasePresenter<FabiBuyAndSellDetailFragment> {
    public Flowable<List<FabiDetailListBean>> getList(int page, int size, boolean isBuy) {
        return  OkGo.<HttpData<HaiPageBean<FabiDetailListBean>>>post(HttpConfig.BASE_URL + (isBuy?HttpConfig.ORDER_LIST_BUY:HttpConfig.ORDER_LIST_SELL))
                .params("p", page)
                .params("size", size)
                .converter(new JsonConverter<HttpData<HaiPageBean<FabiDetailListBean>>>() {})
                .adapt(new FlowableBody<>())
                .map(haiPageBeanHttpData -> haiPageBeanHttpData.getData().getRes());
    }
}
